
#ifndef  TABLEORDER_H
#define  TABLEORDER_H


#include "common.h"
#include "Table.h"
#include <boost/thread/mutex.hpp>

class Index;
class IKvContainer;

class TableOrder : public Table {
public:
    TableOrder();
    virtual ~TableOrder();

    int init() override;
    void deinit() override;

    int insert(const int key, const char * value) override ;
    int update(const int key, const char * value) override;
    int remove(const int key) override;
    const char * find(const int key) const override;

    Records * rangeScan(int offset, int count, bool isAscend, const std::string & indexName) const override;

    int totalCount();

    std::string toString() const override;

    static void test();
private:
    void clear(); //for clear indexes & data<,char*>

private:
    IKvContainer * data;
    std::unordered_map<std::string, Index*> indexes;
    mutable boost::mutex mutex;
};



#endif   /* TABLEORDER_H */
